package com.example.girl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

//@RestController

@Controller
@ResponseBody
@RequestMapping("/hello")
public class HelloController {

    @Autowired
    GirlProperties girlProperties;


    // 演示：解决多个请求路径映射到同一个资源
//    @RequestMapping(value = {"/hello","/hi"}, method = RequestMethod.GET)
//    public String say(){
//        return girlProperties.getAge() + girlProperties.getCupSize();
//        //return "index"; // 演示：数据在模板中显示
//    }

    // 演示：获取请求路径中的参数
    @RequestMapping(value = "/say")
    //@GetMapping("/say")
    //@PostMapping("/say")
    public String say( @RequestParam(value = "id", required = false, defaultValue = "100") Integer myId){
        return  "PathVariable :" + myId +   girlProperties.getAge() + girlProperties.getCupSize();
    }



}
